# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=jom
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgdesc="JOM - the parallel make tool for Windows (mingw-w64)"
pkgver=1.1.3
pkgrel=2
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://wiki.qt.io/Jom'
license=('GPL3')
depends=("${MINGW_PACKAGE_PREFIX}-qt5-base")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake")
options=('strip' 'staticlibs')
#options=('!strip' 'debug' 'staticlibs')
source=("${_realname}-v${pkgver}.tar.gz::https://codereview.qt-project.org/gitweb?p=qt-labs/jom.git;a=snapshot;h=refs/tags/v${pkgver};sf=tgz")
sha256sums=('1207452997f428505203741a4de4bb7b35fb37b357bf56092280c57c8e47d18b')

build() {
  cd "${srcdir}"
  [[ -d build-${MSYSTEM} ]] && rm -rf build-${MSYSTEM}
  mkdir build-${MSYSTEM} && cd build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    ../${_realname}-v${pkgver}

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-v${pkgver}/LICENSE.GPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
